<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class WarehouseOutLog extends Model
{
    protected $table = 'warehouse_out_logs';

    protected $fillable = [
        'foreign', 'foreign_key', 'warehousing_id', 'ip', 'remark'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\MorphTo
     * @author luffyzhao@vip.126.com
     */
    public function user(){
        return $this->morphTo('' , 'foreign', 'foreign_key');
    }

    protected static function boot()
    {
        static::addGlobalScope('orderBy', function (Builder $query){
            $query->orderByDesc('id');
        });
        parent::boot();
    }
}
